package com.example.demoamqp.send;

import com.example.demoamqp.conatants.Constants;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * @className: FanoutSender
 * @projectName: demo-one
 * @auth: rosszhang
 * @date: 2023/12/28 15:20
 */
@Slf4j
@Component
public class FanoutSender {
    private AmqpTemplate rabbitAmqpTemplate;

    @Autowired
    public void setRabbitAmqpTemplate(AmqpTemplate rabbitAmqpTemplate) {
        this.rabbitAmqpTemplate = rabbitAmqpTemplate;
    }

    public void sendCode(String msg) {
        rabbitAmqpTemplate.convertAndSend(
                Constants.MQ_FANOUT_EXCHANGE,
                "routingkey.fanout",
                msg);
        log.debug("[生产者向交换机：] 发送一条信息：{}",msg);
    }


}
